Warn when XML subelement text exceeds lxml 2 GB limit#3953
Open
EdenRochmanSharabi wants to merge 1 commit into
Open
Warn when XML subelement text exceeds lxml 2 GB limit#3953EdenRochmanSharabi wants to merge 1 commit into
EdenRochmanSharabi wants to merge 1 commit into
Conversation
lxml silently produces empty elements when text content exceeds 2 GB. Add a size check before assigning text to temperature, density, and distributed material subelements in Cell, raising a ValueError with a clear message instead of silently writing blank data. Closes openmc-dev#3838
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3838
lxml silently writes an empty sub-element when its text content reaches 2 GB. This causes data loss without any error or warning (e.g. hundreds of millions of cell temperatures vanish from the exported XML).
This PR adds a
_check_text_sizehelper inopenmc/_xml.pythat raises aValueErrorbefore the assignment when the text is too large. The check is applied to the three Cell sub-elements that can realistically hit the limit: temperature, density, and distributed materials.Reproducer from the issue now raises: